import { DailyItem } from "./DailyItem";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { DailyInfo } from "../../../model/DailyInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { CopyUtil } from "../../copy/CopyUtil";
//class DailyCopyItem
    
    export  class DailyCopyItem extends DailyItem
    {
        constructor()
        {
            super();
            return;
        }

        public /* override */ initUI(): void
        {
            super.initUI();
            _itemName.x = 30;
            _itemLevel.x = _itemLevel.x + 40;
            _itemTime.x = _itemTime.x - 10;
            _itemOpt.x = _itemOpt.x - 70;
            this._optBtn = new GButton();
            this._optBtn.label = Language.getString(20981);
            this._optBtn.setSize(46, 20);
            this._optBtn.styleName = "DialogOptBtn2";
            this._optBtn.textField.filters = [FilterConst.nameGlowFilter];
            this._optBtn.x = 375;
            this._optBtn.y = _itemName.y;
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptBtnClickHandler);
            return;
        }

        protected onOptBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShowDelegateTaskWindow, _info.copyId));
            return;
        }

        public /* override */ updateData(arg1: DailyInfo): void
        {
            super.updateData(arg1);
            _itemTime.htmlText = HTMLUtil.addColor(arg1.actType, _color);
            if (_info.countTotal != 0) 
            {
                _itemName.htmlText = _itemName.htmlText + HTMLUtil.addColor("(" + _info.count + "/" + _info.countTotal + ")", _nameColor);
            }
            if (CopyUtil.isCanDelegateByCopyId(_info.copyId) && arg1.isCurWeekInfo) 
            {
                if (!contains(this._optBtn)) 
                {
                    addChild(this._optBtn);
                }
            }
            else if (contains(this._optBtn)) 
            {
                removeChild(this._optBtn);
            }
            return;
        }

        protected /* var */_optBtn: GButton;
    }
